home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / addition.c next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  998 b   |  41 lines

  1. /*
  2.                             A D D I T I O N . C
  3. */
  4.  
  5. #include "iccomp.h"
  6.  
  7. ESTRUC_ *addition (lval, rval)
  8.     ESTRUC_
  9.         *lval,
  10.         *rval;
  11. {
  12.     register E_TYPE_
  13.         type;
  14.  
  15.     if (test_binop(op_add, lval, rval))
  16.         return (lval);                      /* test for correct types */
  17.  
  18.     btoi(lval);                             /* convert pending booleans */
  19.     btoi(rval);
  20.  
  21.     if (conflict(lval, rval, op_add))       /* test type conflict */
  22.         return(lval);
  23.  
  24.     type = lval->type;                      /* keep type for later */
  25.  
  26.     if ((type & rval->type & ~ALLTYPES) == e_const)
  27.     {
  28.         if (test_type(lval, e_int))
  29.             lval->evalue += rval->evalue;
  30.         else if (test_type(lval, e_str))
  31.             catstrings(lval, rval);         /* create (cat) new string */
  32.     }
  33.     else
  34.     {
  35.         defcode(lval, rval, op_add);
  36.         set_type(lval, (type & ALLTYPES) | e_code);
  37.     }
  38.  
  39.     return (lval);                          /* return new expression */
  40. }
  41.